#include <err.h>
#include <getopt.h>
#include <stdio.h>
#include <unistd.h>

#include "../getopt_helper.h"

static struct option const LONG_OPTIONS[] = { GETOPT_END_DECL };

const char usage_str[] =
    "Usage: %s [OPTION]\n"
    "Print the name of the current user.\n"
    "\n"
    "      --help     display this help and exit\n"
    "      --version  output version information and exit";

int
main(int argc, char *argv[])
{
	int ch;
	while ((ch = getopt_long(argc, argv, "", LONG_OPTIONS, NULL)) != -1) {
		switch (ch) {
			GETOPT_END_CASE
		}
	}

	GETOPT_NO_EXTRA_ARGS(argc);

	const char *user = getlogin();

	if (!user) err(!0, NULL);

	puts(user);

	return 0;
}
